<?php
class ZendX_Resource_Loader implements Zend_Loader_Autoloader_Interface {
	
	protected $_baseDir = NULL;
	
	public function __construct(array $options) {
		$this->_baseDir = $options['basePath'];
		$this->_namespace = $options['namespace'];

		Zend_Loader_Autoloader::getInstance()->pushAutoloader($this);
	}
	
	public function autoload($class) {
		$parts = explode('_', $class);

		if($parts[0] !== $this->_namespace) {
			return false;
		}

		$class_name = ucfirst($parts[1]);
		$path = "{$this->_baseDir}/$class_name.php";
		if(!file_exists($path)) {
			return false;
		}

		Zend_Loader::loadFile($path, null, true);
		return true;
	}
	
}